package com.small.admin.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import com.small.common.base.service.impl.BaseServiceImpl;
import com.small.common.msg.MsgPage;
import com.small.common.msg.UserMsgPage;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.small.admin.dto.UserPage;
import com.small.admin.entity.SysUser;
import com.small.admin.mapper.SysUserMapper;
import com.small.admin.service.SysUserService;

/**
 * 作者: guoshun
 * 邮箱: 2855052663@qq.com
 * 时间: 2018-10-26 16:21:00
 * 描述: 系统用户
 */
@Service
public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Override
    public UserMsgPage<SysUser> selectByPage(UserPage userPage) {
        Page<Object> result = PageHelper.offsetPage(userPage.getOffset(), userPage.getLimit());
        List<SysUser> list = mapper.selectByPage(userPage);
        UserMsgPage<SysUser> userMsgPage = new UserMsgPage<>(list);
        userMsgPage.setTotal(result.getTotal());
        return userMsgPage;
    }
    @Override
    public void add(SysUser sysUser){
        insertSelective(sysUser);
    }
}